package com.mulitidatasource.controller;

import java.sql.Clob;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.mulitidatasource.mapper.db1.Db1Test;
import com.mulitidatasource.mapper.db2.Db2Test;

@RestController
public class DbController {
    @Autowired
    private Db1Test db1Test;
    
    @Autowired
    private Db2Test db2Test;
	@RequestMapping(value="/testDb",method=RequestMethod.GET)
	public String testDb() throws SQLException{
		List<Map<String, Clob>> map1 = db1Test.select();
		List<Map<String, Clob>> map2 = db2Test.select();
//		for(Map<String, Clob> map : map1){
//			for(String key : map.keySet()){
//				Clob clob = map.get(key);
//				System.out.println("db1:" + key + ":" + clob.getSubString(1L, (int)clob.length()));
//				break;
//			}
//		}
//		for(Map<String, Clob> map : map2){
//			for(String key : map.keySet()){
//				Clob clob = map.get(key);
//				System.out.println("db2:" + key + ":" + clob.getSubString(1L, (int)clob.length()));
//				break;
//			}
//		}
		System.out.println(map1.size());
		System.out.println(map2.size());
		return "success";
	}
}
